using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Collections.Specialized;
using System.Windows.Data;

namespace GMUtilitiesDotNet.Gestures
{
    /// <summary>
    /// Collection containing GestureCommands.
    /// Collection can listen to UiElement's events (from mouse, keyboard etc.) and 
    /// dispatch events to gestures.
    /// 
    /// Collection derives from Freezable in order to inherit context and support 
    /// element name bindings per Mike Hillberg blog post.
    /// </summary>
    public class GestureCommandsCollection : FreezableCollection<GestureCommand>
    {
        /// <summary>
        /// Helper object used for UI events dispatching to gestures
        /// </summary>
        private UiEventsDispatcher UiEventsDispatcher { get; set; }

        /// <summary>
        /// Creates dispatcher and links it to gesture list
        /// </summary>
        public GestureCommandsCollection()
        {
            UiEventsDispatcher = new UiEventsDispatcher(this);
        }

        /// <summary>
        /// Subscribes dispatcher to UI element
        /// </summary>
        /// <param name="target"></param>
        public void Subscribe(UIElement uiElement)
        {
            UiEventsDispatcher.Subscribe(uiElement);
        }

        /// <summary>
        /// Unsubscribes dispatcher to UI element
        /// </summary>
        /// <param name="target"></param>
        public void Unsubscribe(UIElement uiElement)
        {
            UiEventsDispatcher.Unsubscribe(uiElement);
        }
    }
}
